import { ResPage, User } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取用户列表
export const getUserList = (params: User.ReqUserParams) => {
  return http.post<ResPage<User.ResUserList>>(PORT1 + `/user/page`, params);
};
// 新增用户
export const addUser = (params: any) => {
  return http.post(PORT1 + `/user/add`, params);
};
// 编辑用户
export const editUser = (params: User.EditUserParams) => {
  return http.post(PORT1 + `/user/edit`, params);
};
// 删除用户
export const deleteUser = (params: { userId: number }) => {
  return http.post(PORT1 + `/user/delete`, params);
};
// 切换用户状态
export const changeUserStatus = (params: { userId: number; userStatus: number }) => {
  return http.post(PORT1 + `/user/change`, params);
};
// 重置用户密码
export const resetUserPassWord = (params: { userId: number }) => {
  return http.post(PORT1 + `/user/reset`, params);
};
// 修改密码
export const changeUserPassWord = (params: { userId: number; oldPassword: string; newPassword: String }) => {
  return http.post(PORT1 + `/user/password`, params);
};
// 获取单个用户信息
export const getUserInfo = (params: { userId: number }) => {
  return http.post<User.ResUserList>(PORT1 + `/user/get`, params);
};

////////////////////////////////////////////////////////////////
// 批量添加用户
export const BatchAddUser = (params: FormData) => {
  return http.post(PORT1 + `/user/import`, params);
};

// 导出用户数据
export const exportUserInfo = (params: User.ReqUserParams) => {
  return http.download(PORT1 + `/user/export`, params);
};
